package service.impl;

import dao.FavouriteDao;
import dao.impl.FavouriteDaoImpl;
import pojo.Favourite;
import service.FavouriteService;

import java.sql.SQLException;
import java.util.ArrayList;

public class FavouriteServiceImpl implements FavouriteService {
    private FavouriteDao favouriteDao = new FavouriteDaoImpl();
    private boolean flag = false;


    public ArrayList<Favourite> favourites(Integer uid) throws SQLException, ClassNotFoundException {
        ArrayList<Favourite> favouriteList = new ArrayList<>();
        favouriteList = favouriteDao.favouriteList(uid);
        return favouriteList;
    }


    public boolean userFavouriteNote(Integer uid, Integer nid) throws SQLException {
        flag = favouriteDao.UserFavouriteNote(uid, nid);
        return flag;
    }

    public Integer noteFavourites(Integer nid) throws SQLException {
        Integer number = 0;
        number = favouriteDao.noteFavouriteTotal(nid);
        return number;
    }


    public boolean isFavourite(Integer uid, Integer nid) throws SQLException {
        flag = favouriteDao.findFavourite(uid, nid);
        return flag;
    }


    public boolean UserUnFavourite(Integer uid, Integer nid) throws SQLException {
        flag = favouriteDao.UserUnFavourite(uid, nid);
        return false;
    }
}
